#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>

using namespace std;

class Fruit
{
public:

	virtual void show() = 0;
};

class Apple : public Fruit
{
public:

	void show()
	{
		cout << "I am Apple" << endl;
	}
};


class Banana : public Fruit
{
public:
	void show()
	{
		cout << "I am Banana" << endl;
	}
};

class Animal
{
public:

	virtual void voice() = 0;
};

class Pig : public Animal
{
public:

	void voice()
	{
		cout << "I am Pig" << endl;
	}
};

class Dog : public Animal
{
public:

	void voice()
	{
		cout << "I am Dog" << endl;
	}
};

class Factory
{
public:
	virtual Fruit* Fcreate() = 0;
	virtual Animal* Acreate() = 0;
};

class AFactory : public Factory
{
public:
	Fruit* Fcreate() override
	{
		
		return new Apple();
	}
	Animal* Acreate() override
	{
		return new Pig();
	}
};

class BFactory : public Factory
{
public:
	Fruit* Fcreate() override
	{

		return new Banana();
	}
	Animal* Acreate() override
	{
		return new Dog();
	}
};

int main()
{
	Factory* t = new AFactory();
	Animal *a1 = t->Acreate();
	Fruit* a2 = t->Fcreate();
	a1->voice();
	a2->show();

	Factory* t1 = new BFactory();
	Animal* b1 = t1->Acreate();
	Fruit* b2 = t1->Fcreate();
	b1->voice();
	b2->show();
	return 0;
}